home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / Development / PowerD / alpha / ddbg / ddbg_trace.ass next >
Encoding:
Text File  |  2002-10-28  |  2.6 KB  |  145 lines

  1. ; Code by Zbigniew `Zeeball` Trzcionkowski
  2. ; At: 19.02.2000
  3. ; Use it for free just credit me!
  4.  
  5. ; 2.6.2002 by Martin <MarK> Kuchinka:
  6. ; small changes to make the code more relevant for PowerD debugger
  7.  
  8. ; history
  9. ; 16.8.2002 changes by MarK
  10. ;   the tracing routine speeded up by skipping all the non-proggy code
  11.  
  12.     machine    68010
  13.  
  14. ; Trace(code:a0,test:a1)(pc,reglist)
  15.     xdef    _Trace
  16. _Trace    movem.l    a5-a6,-(a7)
  17.     movea.l    $4.w,a6
  18.     jsr    (-132,a6)        ; Forbid
  19.     jsr    (-$78,a6)        ; Disable
  20.  
  21.     lea    (Trail,pc),a5
  22.     move.l    a0,(-4,a5)
  23.     move.l    a1,(-8,a5)
  24.     move.l    a2,(-16,a5)
  25.     move.l    a3,(-12,a5)
  26.     jsr    (-30,a6)        ; Supervisor
  27.  
  28.     jsr    (-$7e,a6)        ; Enable
  29.     jsr    (-138,a6)        ; Permit
  30.     movem.l    (a7)+,a5-a6
  31.     move.l    (addy,pc),d0
  32.     lea    (reglist,pc),a0
  33.     move.l    a0,d1
  34.     rts
  35.  
  36.  
  37. start    dc.l    0
  38. stop    dc.l    0
  39. test    dc.l    0
  40. Procedura    dc.l    0
  41. Trail    movem.l    d0-a6,-(sp)
  42.  
  43.     ; get vbr 68000-68060 compatible
  44.     suba.l    a1,a1
  45.     movea.l    $4.w,a6
  46.     move.w    ($128,a6),d0    ; ExecBase.AttnFlags
  47.     btst    #0,d0        ; 68010+?
  48.     beq.b    .xvbr
  49.     movec    VBR,a1        ; yes, get VBR
  50. .xvbr
  51.     move.l    ($24,a1),-(sp)
  52.     move.l    a1,-(sp)
  53.  
  54.     lea    (Trailer,pc),a0
  55.     move.l    a0,($24,a1)    ; setup the tracing function
  56.  
  57.     bsr.b    .change_t        ; enable tracing
  58.  
  59.     move.l    (Procedura,pc),a0
  60.     jsr    (a0)        ; run the code
  61.  
  62.     bsr.b    .change_t        ; disable tracing
  63.  
  64.     move.l    (sp)+,a1
  65.     move.l    (sp)+,($24,a1)
  66.     movem.l    (sp)+,d0-a6
  67.     rte
  68.  
  69. ; change the tracing bit
  70. .change_t    move.w    SR,d0
  71.     bchg    #15,d0
  72.     move.w    d0,SR
  73.     rts
  74.  
  75.  
  76. exitd0    move.l    (sp)+,d0
  77.     rte
  78.  
  79. ; this function is invoked when an instruction is completed
  80. ; it stores the address of the next instruction to be executed to the addy address
  81. Trailer    move.l    d0,-(sp)
  82.     move.l    (6,sp),d0
  83.     cmp.l    (start,pc),d0
  84.     blt.s    exitd0
  85.     cmp.l    (stop,pc),d0
  86.     bgt.s    exitd0
  87.  
  88.     move.l    (sp)+,d0
  89.     movem.l    d0-a6,-(sp)
  90.  
  91.     move.l    a0,-(a7)        ; save all the registers
  92.     lea    (reglist,pc),a0
  93.     move.l    d0,(a0)
  94.     move.l    d1,(4,a0)
  95.     move.l    d2,(8,a0)
  96.     move.l    d3,(12,a0)
  97.     move.l    d4,(16,a0)
  98.     move.l    d5,(20,a0)
  99.     move.l    d6,(24,a0)
  100.     move.l    d7,(28,a0)
  101.     move.l    (a7)+,(32,a0)
  102.     move.l    a1,(36,a0)
  103.     move.l    a2,(40,a0)
  104.     move.l    a3,(44,a0)
  105.     move.l    a4,(48,a0)
  106.     move.l    a5,(52,a0)
  107.     move.l    a6,(56,a0)
  108.     move.l    usp,a1
  109.     move.l    a1,(60,a0)
  110.     move.w    (60,sp),(64,a0)
  111.  
  112.     move.l    a0,a1
  113.     move.l    (62,sp),a0
  114.     move.l    (test,pc),a2
  115.     jsr    (a2)
  116. ; this returns:
  117. ; 0 - everything is ok
  118. ; 1 - raise
  119.  
  120.     tst.l    d0
  121.     beq.b    .exit
  122.  
  123.     lea    (addy,pc),a0
  124.     move.l    (62,sp),(a0)    ; store pc
  125.  
  126.     ; get vbr 68000-68060 compatible
  127.     suba.l    a1,a1
  128.     movea.l    $4.w,a6
  129.     move.w    ($128,a6),d0    ; ExecBase.AttnFlags
  130.     btst    #0,d0        ; 68010+?
  131.     beq.b    .xvbr
  132.     movec    VBR,a1
  133. .xvbr
  134.     ; now enshort the tracing routine to be as small as possible
  135.     ; by setting the tracing exception vector to rte instruction only
  136.     lea    (ski,pc),a0
  137.     move.l    a0,($24,a1)
  138. .ok
  139. .exit    movem.l    (sp)+,d0-a6
  140. ski    rte
  141.  
  142. addy    dc.l    0
  143. reglist    ds.l    17
  144.     xref    _exe
  145.